{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox-title">
        <h5>超重邮费</h5>
    </div>
    <div class="ibox-content layui-form">
        <div class="layui-row layui-col-space10 layui-form-item ">
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">首重(g)：</label>
                <div class="layui-input-block">
                    <input type="text" name="score" lay-verify="" placeholder="首重" class="layui-input" value="{$info.score}" oninput="value=value.replace(/[^\d]/g,'')">
                </div>
            </div>

            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">每超出重量(g)：</label>
                <div class="layui-input-block">
                    <input type="text" name="exp" lay-verify="" placeholder="每超出重量" class="layui-input" value="{$info.exp}" oninput="value=value.replace(/[^\d]/g,'')">
                </div>
            </div>

            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">超出价格(元)：</label>
                <div class="layui-input-block">
                    <input type="text" name="num" lay-verify="" placeholder="超出价格" class="layui-input" value="{$info.remark}" oninput="handleMoney(this);">
                </div>
            </div>

            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                    </button>
                    <!--<button class="layui-btn layui-btn-primary" onclick="history.go(-1)">返回</button>-->
                </div>
            </div>
        </div>
    </div>
</div>

{include file="public/footer" /}
<script>
    layui.use(['form'], function() {
        var form = layui.form;
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('overWeight')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('Signconfig/overWeight')}")
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\')');
                    }
                }
            })
        });
    });
    function handleMoney(obj){ //0代表不要小数，1代表代表保留两位小数
        obj.value = obj.value.replace(/[^\d.]/g, ''); //有.
        obj.value = obj.value.replace(/\.{1,}/g, '.'); //2即两位
        obj.value = obj.value.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.');
        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d).*$/, '$1$2.$3');
        if (obj.value.indexOf('.') < 0 && obj.value != '') {
            obj.value = parseFloat(obj.value);
        }
        if ((obj.value.length == 1 && obj.value == '.') || obj.value.substring(0,1) == '.') {
            obj.value = '';
        }
    }
</script>
</body>
</html>